<?php

namespace App\Models;

use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;
use Illuminate\Pagination\LengthAwarePaginator;

class StudentClass extends Model
{
    use HasFactory, Notifiable;

    /**
     * @var string
     */
    public $table = 'student_class';

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'student_class_name',
    ];

    /**
     * 班级列表
     * @return mixed
     */
    public function getList()
    {
        return $this->get();
    }

    /**
     * 班级添加
     * @param $data
     * @return bool
     */
    public function add($data)
    {
        $this->student_class_name = $data['student_class_name'];
        return $this->save();
    }

    /**
     * 班级删除
     * @param $id
     * @return bool
     */
    public function del($id)
    {
        return $this->where('id', $id)->delete();
    }

    /**
     * 班级修改
     * @param $data
     * @return mixed
     */
    public function edit($data)
    {
        $id = $data['id'];
        unset($data['id']);
        return $this->where('id', $id)->update($data);
    }

    /**
     * 查询班级
     * @param $id
     * @return mixed
     */
    public function getOne($id)
    {
        return $this->findOrFail($id);
    }
}
